GraphViewer = {};
mxGraph.prototype.click = function(b, a) {
    if (b.button == 1) {
        Ext.menu.MenuMgr.hideAll()
    }
};
mxGraph.prototype.dblClick = function(b, a) {
};
mxVertexHandler.prototype.init = function() {
    this.bounds = new mxRectangle(this.state.x, this.state.y, this.state.width, this.state.height);
    this.selectionBorder = new mxRectangleShape(this.bounds, null);
    this.selectionBorder.dialect = (this.graph.dialect != mxConstants.DIALECT_SVG) ? mxConstants.DIALECT_VML : mxConstants.DIALECT_SVG;
    this.selectionBorder.init(this.graph.getView().getOverlayPane())
};
mxEdgeHandler.prototype.init = function() {
    this.points = new Array();
    this.abspoints = this.state.absolutePoints;
    this.shape = new mxPolyline(this.abspoints);
    this.shape.dialect = (this.graph.dialect != mxConstants.DIALECT_SVG) ? mxConstants.DIALECT_VML : mxConstants.DIALECT_SVG;
    this.shape.init(this.graph.getView().getOverlayPane());
    this.shape.node.style.cursor = "pointer";
    var b = this;
    mxEvent.addListener(this.shape.node, "mousedown", function(c) {
        b.graph.dispatchGraphEvent("mousedown", c, b.state.cell)
    });
    mxEvent.addListener(this.shape.node, "mouseup", function(c) {
        b.graph.dispatchGraphEvent("mouseup", c, b.state.cell)
    });
    this.label = new mxPoint(this.state.absoluteOffset.x, this.state.absoluteOffset.y);
    this.labelShape = new mxRectangleShape(new mxRectangle(), null, null);
    this.initBend(this.labelShape);
    var a = this.state.cell;
    this.redraw()
};
mxCellRenderer.prototype.installListeners = function(c) {
    var b = c.view.graph;
    if (b.dialect == mxConstants.DIALECT_SVG) {
        var a = "all";
        if (b.getModel().isEdge(c.cell) && c.shape.stroke != null && c.shape.fill == null) {
            a = "visibleStroke"
        }
        if (c.shape.innerNode != null) {
            c.shape.innerNode.setAttribute("pointer-events", a)
        } else {
            c.shape.node.setAttribute("pointer-events", a)
        }
    }
    var d = b.getCursorForCell(c.cell);
    if (d != null || b.isEnabled()) {
        if (d == null) {
            if (b.getModel().isEdge(c.cell)) {
            } else {
                if (b.isMovable(c.cell)) {
                }
            }
        }
        if (c.shape.innerNode != null && !b.getModel().isEdge(c.cell)) {
            c.shape.innerNode.style.cursor = d
        } else {
            c.shape.node.style.cursor = d
        }
    }
    mxEvent.addListener(c.shape.node, "mousedown", function(e) {
        if (c.shape != null && mxEvent.getSource(e) == c.shape.content) {
            b.dispatchGraphEvent("mousedown", e)
        } else {
            b.dispatchGraphEvent("mousedown", e, c.cell)
        }
    });
    mxEvent.addListener(c.shape.node, "mousemove", function(e) {
        if (c.shape != null && mxEvent.getSource(e) == c.shape.content) {
            b.dispatchGraphEvent("mousemove", e)
        } else {
            b.dispatchGraphEvent("mousemove", e, c.cell)
        }
    });
    mxEvent.addListener(c.shape.node, "mouseup", function(e) {
        if (c.shape != null && mxEvent.getSource(e) == c.shape.content) {
            b.dispatchGraphEvent("mouseup", e)
        } else {
            b.dispatchGraphEvent("mouseup", e, c.cell)
        }
    });
    mxEvent.addListener(c.shape.node, "dblclick", function(e) {
        if (c.shape != null && mxEvent.getSource(e) == c.shape.content) {
            b.dblClick(e)
        } else {
            b.dblClick(e, c.cell)
        }
        mxEvent.consume(e)
    });
    if (c.text != null) {
        var d = b.getCursorForCell(c.cell);
        if (d != null || (b.isEnabled() && b.isMovable(c.cell))) {
            c.text.node.style.cursor = d;
            if (c.cell.id.length == 32) {
                c.text.node.style.cursor = d || "pointer"
            }
        }
        mxEvent.addListener(c.text.node, "mousedown", function(e) {
            if (b.getModel().isEdge(c.cell) && b.isCellSelected(c.cell)) {
                b.dispatchGraphEvent("mousedown", e, c.cell, mxEdgeHandler.prototype.LABEL_INDEX)
            } else {
                b.dispatchGraphEvent("mousedown", e, c.cell)
            }
        });
        mxEvent.addListener(c.text.node, "mousemove", function(e) {
            if (c.cell.id && c.cell.vertex && c.cell.id.length == 32) {
                menu = new Ext.menu.Menu({id:"feeds-ctx",items:[
                    {text:'&nbsp;',iconCls:"op-icon",scope:this},
                    {text:'查看明细',iconCls:"oprule-icon",scope:this,handler:function() {
                        showOperators(c.cell.id);
                    }}
                ]});

                menu.showAt([e.clientX,e.clientY]);
                sql = "select distinct h.id ,h.objname from cs_wfworkitem wo,cs_human h where wo.userid = h.id and wo.opttype>1 and wo.submitted=0 and wo.nodeid = '" + c.cell.id + "' and wo.processid = '" + processid + "'";
                if(currentnodeids.indexOf(c.cell.id)==-1)
                    sql = "select distinct wl.userid as id ,h.objname from cs_wfprocesslog wl,cs_human h  where wl.userid= h.id  and wl.logtype in('71','74','75')  and wl.nodeid = '" + c.cell.id + "' and wl.processid = '" + processid + "'";
                if (menu.items.get(0).text == '&nbsp;')
                    DataService.query(sql, {callback:function (o) {
                        var undousers = '';
                        if (o.length == 0) undousers = '（空）';
                        for (i = 0; i < o.length; i++) {
                            undousers += o[i].objname + '';
                            if(i%5==0) undousers+='<br>';
                            if(i>20){
                                undousers+='...';
                                break;
                            }
                        }
                        menu.items.get(0).setText(undousers);
                    }})
                b.dispatchGraphEvent("mousemove", e, c.cell)
            }
        });
        mxEvent.addListener(c.text.node, "mouseup", function(e) {
            b.dispatchGraphEvent("mouseup", e, c.cell)
        });
        mxEvent.addListener(c.text.node, "dblclick", function(e) {
            b.dblClick(e, c.cell);
            mxEvent.consume(e)
        })
    }
};
mxGraphHandler.prototype.mouseMove = function(b, a) {
};
mxGraphHandler.prototype.mouseUp = function(b, a) {
};
mxGraphHandler.prototype.mouseDown = function(b, a) {
};
mxKeyHandler.prototype.keyDown = function(b, a) {
};
var mainPanel;
function loadGraph(a) {
    Ext.QuickTips.init();
    mxEvent.disableContextMenu(document.body);
    var h = new mxGraph();
    h.setCellStyles(mxConstants.STYLE_ALIGN, mxConstants.ALIGN_CENTER);
    var b = mxUtils.load("resources/default-style.xml").getDocumentElement();
    var c = new mxCodec(b.ownerDocument);
    c.decode(b, h.getStylesheet());
    h.alternateEdgeStyle = "vertical";
    mainPanel = new MainPanel(h);
    var f = new Ext.Viewport({layout:"border",items:mainPanel});
    mainPanel.graphPanel.body.dom.style.overflow = "auto";
    if (mxClient.IS_MAC && mxClient.IS_SF) {
        h.addListener("size", function(j) {
            j.container.style.overflow = "auto"
        })
    }
    h.init(mainPanel.graphPanel.body.dom);
    h.setConnectable(false);
    h.setDropEnabled(false);
    h.setPanning(false);
    h.setTooltips(false);
    h.connectionHandler.createTarget = false;
    var g = h.getDefaultParent();
    var e = mxUtils.load(a).getXml();
    b = e.documentElement;
    var c = new mxCodec(b.ownerDocument);
    h.getModel().beginUpdate();
    c.decode(b, h.getModel());
    h.getModel().endUpdate();
    mxEvent.addMouseWheelListener(function(k, j) {
        if (!mxEvent.isConsumed(k)) {
            if (j) {
                h.zoomIn()
            } else {
                h.zoomOut()
            }
            mxEvent.consume(k)
        }
    });
    var i = new Ext.ToolTip({target:h.container,html:""});
    i.disabled = true;
    h.tooltipHandler.show = function(k, j, l) {
        if (k != null && k.length > 0) {
            if (i.body != null) {
                i.body.dom.firstChild.nodeValue = k
            } else {
                i.html = k
            }
            i.showAt([j,l + mxConstants.TOOLTIP_VERTICAL_OFFSET])
        }
    };
    h.tooltipHandler.hide = function() {
        i.hide()
    };
    var d = new mxKeyHandler(h);
    d.bindKey(107, function() {
        h.zoomIn()
    });
    d.bindKey(109, function() {
        h.zoomOut()
    })
}
;